package com.oazon.moco.bean;

import java.util.ArrayList;
import java.util.List;

public class ProviderAdapt {
	
	private static List<ProviderBean> beans = new ArrayList<ProviderBean>();
	
	static{
		beans.add(new ProviderBean("网易云音乐",165,"wangyi"));
		beans.add(new ProviderBean("豆瓣FM",47,"douban"));
		beans.add(new ProviderBean("QQ音乐",23,"qq"));
		beans.add(new ProviderBean("虾米音乐",152,"xiami"));
	}
	
	public static void addProviderBean(ProviderBean bean){
		beans.add(bean);
	}
	
	public static int provider2id(String provider){
		
		if(provider == null){
			return -1;
		}
		for (ProviderBean providerBean : beans) {
			if(provider.equals(providerBean.getProvider())){
				return providerBean.getId();
			}
		}
		return -1;
	}
	
	public static String provider2name(String provider){
		
		if(provider == null){
			return null;
		}
		for (ProviderBean providerBean : beans) {
			if(provider.equals(providerBean.getProvider())){
				return providerBean.getName();
			}
		}
		return "O2";
	}
	
	public static String id2name(int id){
		
		for (ProviderBean providerBean : beans) {
			if(id == providerBean.getId()){
				return providerBean.getName();
			}
		}
		return null;
	}
	
	
	public static String id2provider(int id){
		
		for (ProviderBean providerBean : beans) {
			if(id == providerBean.getId()){
				return providerBean.getProvider();
			}
		}
		return null;
	}
	
	public static String name2provider(String name){
		
		for (ProviderBean providerBean : beans) {
			if(name.equals(providerBean.getName())){
				return providerBean.getProvider();
			}
		}
		return null;
	}
	
	public static int name2id(String name){
		
		for (ProviderBean providerBean : beans) {
			if(name.equals(providerBean.getName())){
				return providerBean.getId();
			}
		}
		return -1;
	}
}
